# Maintainer: wszqkzqk <wszqkzqk@qq.com>

_realname=oh-my-posh
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=18.6.1
pkgrel=1
pkgdesc="A prompt theme engine for any shell. (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
url="https://github.com/JanDeDobbeleer/oh-my-posh"
license=('spdx:MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-go"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/JanDeDobbeleer/oh-my-posh/archive/refs/tags/v${pkgver}.tar.gz")
sha256sums=('9334629bab9330543107c0ffba4e7a5ff82540cbca5b3b186b27fdff92d956d3')

build() {
    export GOOS=windows
    export GOROOT=${MINGW_PREFIX}/lib/go
    export CGO_CPPFLAGS="${CPPFLAGS}"
    export CGO_CFLAGS="${CFLAGS}"
    export CGO_CXXFLAGS="${CXXFLAGS}"
    export CGO_LDFLAGS="${LDFLAGS}"
    export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"

    cd "$_realname-$pkgver/src"
    go build
}

package() {
    cd "$_realname-$pkgver/src"
    install -Dm 755 ./src.exe "${pkgdir}${MINGW_PREFIX}/bin/oh-my-posh.exe"
    install -Dm 644 "../COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
    install -d "${pkgdir}${MINGW_PREFIX}/share/oh-my-posh/themes"
    install -m 644 ../themes/* -t "${pkgdir}${MINGW_PREFIX}/share/oh-my-posh/themes"
}
